import 'package:boss/color_constant.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:boss/ui/widget/form/chip_form_field.dart';
import 'package:boss/ui/widget/label_button.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:router/annotation.dart';

@RouterConfig(MiniProgramCommodityHotTopPage.pageName)
class MiniProgramCommodityHotTopPage extends StatefulWidget {
  static const pageName = '/MiniProgramCommodityHotTopPage';

  @override
  _MiniProgramCommodityHotTopPageState createState() => _MiniProgramCommodityHotTopPageState();
}

class _MiniProgramCommodityHotTopPageState extends BaseState<MiniProgramCommodityHotTopPage> {
  _MiniProgramCommodityHotTopPageState() : super(MiniProgramCommodityHotTopPage.pageName);

  final hotDayItems = [
    ChipFormData(title: '7天', value: 7),
    ChipFormData(title: '30天', value: 30),
  ];

  final hotCountItems = [
    ChipFormData(title: '5个', value: 5),
    ChipFormData(title: '10个', value: 10),
  ];

  int hotDay;

  int hotCount;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CenterTitleAppBar(
        title: '设置热销菜展示规则',
        actions: [
          LabelButton(
            title: '保存',
            onTap: save,
            padding: EdgeInsets.only(left: 4, top: 2, bottom: 2),
            textStyle: TextStyleConstant().blue_28,
          )
        ],
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          buildHeader(),
          buildContent(),
        ],
      ),
    );
  }

  Widget buildHeader() {
    return DefaultTextStyle(
      style: TextStyleConstant().normal_4_24,
      child: Container(
        padding: EdgeInsets.symmetric(vertical: 20.w, horizontal: 30.w),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('以下菜品将不会通过热销菜排行榜展示给顾客：'),
            Text('1."米饭"、"打包盒"、"餐具"等非传统菜'),
            Text('2.店内单价偏低的菜品'),
          ],
        ),
      ),
    );
  }

  void save() {}

  Widget buildContent() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 30.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          ChipFormField<int>(
            title: '热销菜取近几天销量',
            items: hotDayItems,
            selectedItems: [hotDay],
          ),
          ChipFormField<int>(
            title: '热销菜最多展示几个',
            items: hotCountItems,
            selectedItems: [hotCount],
          ),
        ],
      ),
    );
  }
}
